<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8" />
<title>模板管理 - 广告内容</title>
<?php include($this->c['_homes']['_viewsHome'].'/_global/_head.php');?>
</head>
<!-- BEGIN BODY -->
<body class="page-header-fixed page-sidebar-fixed">
<!-- BEGIN HEADER -->
<?php include($this->c['_homes']['_viewsHome'].'/_global/head.php');?>
<!-- END HEADER -->
<div class="clearfix"></div>
<!-- BEGIN CONTAINER -->
<div class="page-container" > 
  <!-- BEGIN HORIZONTAL MENU PAGE SIDEBAR1 -->
  <?php include($this->c['_homes']['_viewsHome'].'/_global/menu.php');?>
  <!-- END BEGIN HORIZONTAL MENU PAGE SIDEBAR --> 
  <!-- BEGIN PAGE -->
  <div class="page-content"> 
  	<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->               
     <div class="modal fade" id="portlet-config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
           <div class="modal-content">
              <div class="modal-header">
                 <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                 <h4 class="modal-title">Modal title</h4>
              </div>
              <div class="modal-body">
                 Widget settings form goes here
              </div>
              <div class="modal-footer">
                 <button type="button" class="btn blue submit_btn">确定</button>
                 <button type="button" class="btn default" data-dismiss="modal">取消</button>
              </div>
           </div>
           <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
     </div>
     <!-- /.modal -->
     <!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->
    <!-- BEGIN PAGE HEADER-->
    <div class="row">
      <div class="col-md-12"> 
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <h3 class="page-title"> 广告内容 </h3>
        <ul class="page-breadcrumb breadcrumb">
          <li class="btn-group">
            <button type="button" class="btn blue dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-delay="1000" data-close-others="true"> <span>操作</span> <i class="icon-angle-down"></i> </button>
            <ul class="dropdown-menu pull-right" role="menu">
				  <li><a href="/tpl/homeadd"><i class="icon-plus"></i> 新增版块</a></li>
				  <li><a href="/tpl/homesort"><i class="icon-sort-by-attributes"></i> 版块排序</a></li>            
             </ul>
          </li>
          <li> <i class="icon-home"></i> <a href="/manage">后台</a> <i class="icon-angle-right"></i> </li>
          <li> 模板管理 <i class="icon-angle-right"></i> </li>
          <li>广告内容</li>
        </ul>
        <!-- END PAGE TITLE & BREADCRUMB--> 
      </div>
    </div>
    <!-- END PAGE HEADER--> 
    <!-- BEGIN PAGE CONTENT-->
    
    <div class="row">
      <div class="col-md-9"> 
        <!-- BEGIN SAMPLE TABLE PORTLET-->
        <div class="portlet box blue">
          <div class="portlet-title">
            <div class="caption"><i class="icon-reorder"></i>列表</div>
            <div class="tools"> <a href="javascript:;" class="collapse"></a> </div>
          </div>
          <div class="portlet-body">
          <div class="alert alert-info">
          <strong>首页顶部滚动广告</strong>最多3个，超过3个不显示。<br>
          <strong>首页六个固定广告</strong>最多6个，超过6个不显示。<br>
          <strong>商品列表顶部广告</strong>最多1个，超过1个不显示。<br>
          <strong>悦纷享顶部广告</strong>最多1个，超过1个不显示。<br>
          可使用排序来设置显示。</div>
          </div>
          <div class="portlet-body">
            <table class="table table-hover">
              <thead>
                <tr>
                  <th>版块名称</th>
                  <th>小标题</th>
                  <th>状态</th>
                  <th>操作</th>                  
                </tr>
              </thead>
              <?php
			  if($this->data){
				foreach($this->data as $k=>$r){
					?>	
                    <tbody>
                    <tr class="note note-info">                    
                    <td><?=$r['title'];?></td>
                    <td><?=$r['title_tiny'];?></td>
                    <td><?=$this->c['stat']['normal'][$r['stat']];?></td>
                    <td> 
                    	<a href="/tpl/homead_add?htid=<?=$r['htid'];?>" class="btn btn-xs blue"><i class="icon-plus"></i> 增加</a>                   
                        <? if(!$r['static']){?>
                        <a href="/tpl/homeedit?htid=<?=$r['htid'];?>" class="btn btn-xs blue"><i class="icon-edit"></i> 编辑</a>
						<a href="#portlet-config" data-toggle="modal" onclick="_delete_alert('tpl',<?=$r['htid'];?>);" class="btn btn-xs red"><i class="icon-remove"></i> 删除</a><? }?>
                        <a href="/tpl/homead_sort?htid=<?=$r['htid'];?>" class="btn btn-xs blue"><i class="icon-sort-by-attributes"></i> 排序</a>                        
                    </td>
                    </tr>
                    <?php
					if($this->ads[$r['htid']]){
						foreach($this->ads[$r['htid']] as $j=>$s){
							if($r['stat']>1) $s['stat'] = $r['stat'];
						?>
                        <tr>
                        <td style="padding-left:30px;"><?=$s['title'];?></td>
                        <td></td>
                        <td><?=$this->c['stat']['normal'][$s['stat']];?></td>
                        <td>
                        <a href="/tpl/homead_edit?htid=<?=$s['htid'];?>&adid=<?=$s['adid'];?>" class="btn btn-xs blue"><i class="icon-edit"></i> 编辑</a>
                        <a href="#portlet-config" data-toggle="modal" onclick="_delete_alert('ad',<?=$s['adid'];?>);" class="btn btn-xs red"><i class="icon-remove"></i> 删除</a></td>
                        </tr>
                        <?	
						}
					}?>
                    	
                    
                    </tbody>
                <?
				}
			  }
			  ?>
            </table>
          </div>
        </div>
        <!-- END SAMPLE TABLE PORTLET--> 
      </div>
    </div>
    <!-- END PAGE CONTENT--> 
  </div>
  <!-- END PAGE --> 
</div>
<!-- END CONTAINER -->
<?php include($this->c['_homes']['_viewsHome'].'/_global/_footer.php');?>
<form method="post" id="_frm" action="/tpl/homedo">
<input type="hidden" name="act" id="_act" value="delete">
<input type="hidden" name="dataid" id="_dataid" value="0">
</form>
<script>
var _submit_action = '',_dataid = 0;
jQuery(document).ready(function() {    
	App.init();
	$(".submit_btn").bind("click",function(){
		$("#_dataid").prop("value",_dataid);
	 	switch(_submit_action){
			case "tpl":
				_delete_tpl();
				break;
			case "ad":
				_delete_ad();
				break;	
		}
	});
});

function _delete_alert(tp,dataid){
	_submit_action = tp;
	_dataid = dataid;
	if(tp=="tpl"){
		$("#portlet-config .modal-title").html('删除版块');
		$("#portlet-config .modal-body").html('<p>确定删除此版块及下属广告吗？</p> <p class="alert alert-danger">警告：删除后不可恢复</p>');
	}
	else if(tp=="ad"){
		$("#portlet-config .modal-title").html('删除广告');
		$("#portlet-config .modal-body").html('<p>确定删除此广告吗？</p> <p class="alert alert-danger">警告：删除后不可恢复</p>');
	}
}
function _delete_tpl(){
	$("#_frm").prop("action","/tpl/homedo");
	$("#_frm").submit();
}
function _delete_ad(){
	$("#_frm").prop("action","/tpl/savehomead");
	$("#_frm").submit();
}
</script> 
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>